<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'result.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript">

$(function(){
	$("#button").click(function(){
		vilidateUser();
	});
})


function vilidateUser(){

	var params={
			userName:$.trim($("#userName").val())
	};
	$.ajax({
		  type: "POST",
		  url: "register.action",
		  dataType:'json',
		  data:params,
		  success:function(data){
		  	if(data=="0"){
		  		alert("已经存在");
		  	}else{
		  		alert("注册成功");
		  	}
		  }		
	});
}

</script>



  </head>
  
  <body>
     your name is:<%=request.getAttribute("username")%>. <br>  
     
    
	<a href="ShowPage.action">测试列表页面</a>  
	<fieldset>
		<legend>测试AJAX</legend>
	
		<div>
		<label for="Name">用户名</label>
			<input type="text" name="userName"   id="userName" maxlength="20" /> 
			
		<br />	
	
		
		<div class="enter">
	    <input id="button" type="button" class="buttom" value="确认" />
	 
	</div>

	</fieldset>
	
  </body>
</html>
